package com.quectel.sdk.zlm;

import com.quectel.sdk.ex.hikisc.HikFactoryErrorException;
import com.quectel.sdk.zlm.common.ZlmClient;

/**
 * zlm中间件实例建造器
 *
 * @author: rananxin
 * @email: ryan.ran@quectel.com
 * @date: 2022-10-19 11:01:00
 */
public class ZlmMediaKitClientBuilder {

    /**
     * zlm地址
     */
    private String host;
    /**
     * secret访问凭证
     */
    private String secret;

    private ZlmMediaKitClientBuilder() {
    }

    public static ZlmMediaKitClientBuilder builder() {
        return new ZlmMediaKitClientBuilder();
    }

    public ZlmMediaKitClientBuilder host(String host) {
        this.host = host;
        return this;
    }

    public ZlmMediaKitClientBuilder secret(String secret) {
        this.secret = secret;
        return this;
    }

    public ZlmClient build() {
        if (host == null || secret == null) {
            throw new HikFactoryErrorException("Missing request parameter.");
        }
        try {
            ZlmClient t = new ZlmClient();
            t.setRequester(ZlmMediaKitRequester.getInstance(host, secret));
            return t;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
